package com.leandrosantos.sistemasvendas;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

	private static final SessionFactory SESSION_FACTORY = buildSessionFactory();

	private static SessionFactory buildSessionFactory() {

		try {
			
			Configuration configuration = new Configuration();
			configuration.configure("hibernate.cfg.xml");
			return configuration.buildSessionFactory();
			
		} catch (Throwable e) {
			
			System.out.println("Erro ao conectar no Banco de Dados!\n"+e.getMessage()+"\\0>");
			throw new ExceptionInInitializerError();
			
		}

	}

	public static SessionFactory getSessionFactory() {
		
		return SESSION_FACTORY;
		
	}

}
